<%@page language="java" pageEncoding="UTF-8" %>
<%@page contentType="text/html;charset=UTF-8" %>
<%@page import="java.util.*" %>
<HTML>
 
  <BODY>
  <%
      request.setCharacterEncoding("UTF-8");
      String promt=new String();
    String Name=request.getParameter("UserName");
    boolean hasLog=false;
    ArrayList names= (ArrayList)session.getAttribute("lognames");
    if(names==null){
    names=new ArrayList();
    names.add(Name);
    session.setAttribute("lognames",names);
     promt=" 欢迎登录 ！你的名字已经写入session ";
    }else{
   for(int i=0;i<names.size();i++){
    String temp=(String)names.get(i);
    if(temp.equals(Name)){
    promt="你已经登录";
    hasLog=true;
    break;
    }
    }
    if(!hasLog){
    names.add(Name);
    session.setAttribute("lognames",names);
    promt=" 欢迎登录 ！你的名字已经写入session ";
    }
    }
  %>
  <br>
  <%=promt%>
  </BODY>
</HTML>

